<template>
  <div class="grid_cont">
    <div style="display: flex">
      <div style="width: 3px; height: 18px; background-color: rgba(204, 53, 47, 1)"></div>
      <div style="margin-left: 10px; font-size: 16px; line-height: 16px">详情</div>
    </div>
    <div
      style="
        width: 100%;
        height: 1px;
        background-color: rgba(245, 245, 245, 1);
        margin-top: 16px;
        margin-bottom: 30px;
      "
    >
    </div>
    <el-form ref="formRef" :model="formParams" style="margin-left: 14px" label-width="140px">
      <el-form-item  label="选择分类：" prop="articleType">
        <el-input
          disabled
          v-model="formParams.articleType"
          placeholder=""
          placement="bottom"
          style="max-width: 730px"
        />
      </el-form-item>
      <el-form-item  label="标题：" prop="topic">
        <el-input disabled v-model="formParams.topic" style="max-width: 730px" />
      </el-form-item>
      <el-form-item  label="文章来源：" prop="articleSource">
        <el-input disabled v-model="formParams.articleSource" style="max-width: 730px" />
      </el-form-item>
      <el-form-item  label="内容：" prop="content">
        <div style="max-width: 730px; text-align: left">
          <div class="introducestyle">
            <Editor
              v-model="formParams.content"
              style="max-width: 730px; cursor: not-allowed"
              :editor-config="editorConfig"
            />
          </div>
        </div>
      </el-form-item>
      <el-form-item  label="封面图片：" prop="attachmentUrl">
        <UploadImg
          disabled
          v-model="formParams.attachmentUrl"
          :limit="1"
          width="320px"
          height="124px"
        />
      </el-form-item>
    </el-form>
  </div>
  <div style="background: #fff; padding: 0 16px">
    <div style="display: flex; margin-bottom: 20px">
      <div style="width: 3px; height: 18px; background-color: rgba(204, 53, 47, 1)"></div>
      <div style="margin-left: 10px; font-size: 15px; line-height: 16px">是否展示</div>
    </div>
    <el-form :model="formParams" style="margin-left: 14px" label-width="140px">
      <el-form-item  label="文章阅读数：" prop="isDisplay">
        <el-radio-group v-model="formParams.isDisplay">
          <el-radio disabled label="1">是</el-radio>
          <el-radio disabled label="2">否</el-radio>
        </el-radio-group>
      </el-form-item>
    </el-form>
  </div>
  <div class="grid_cont2">
    <el-button class="grid_btn" @click="detailsbtn">返回</el-button>
  </div>
</template>

<script lang="ts" setup>
import * as getArticleApi from '@/api/appManagement/articleManagement/index'
import globalApi from '@/api/spb/global'
import { ref } from 'vue'
const { push } = useRouter() // 路由
const route = useRoute()
const treeData = ref([])
const editorConfig = ref({
  MENU_CONF: {},
  readOnly: readonly
})
const formParams = reactive({
  articleType: '',
  topic: '',
  articleSource: '',
  content: '',
  attachmentUrl: '',
  isDisplay: '1',
  title: ''
})

/** 返回 */
const detailsbtn = () => {
  push({
    name: 'articleManagement'
  })
}
/** 获取分类列表 */
const getDictData = () => {
  const params = {
    pageNo: 1,
    pageSize: 100,
    dictType: 'countryside_app_article_type'
  }
  globalApi.getDictData(params).then((res) => {
    treeData.value = res.list
  })
}
const detailType = (val) => {
  let content = ''
  if (treeData.value) {
    treeData.value.forEach((t) => {
      if (t.value == val) {
        content = t.label
      }
    })
  }
  return content
}
const getData = () => {
  getArticleApi.getArticleDetail(route.query.id).then((res) => {
    formParams.topic = res.topic
    formParams.articleSource = res.articleSource
    formParams.content = res.content
    formParams.attachmentUrl = res.attachmentUrl
    formParams.isDisplay = String(res.isDisplay)
    formParams.articleType = detailType(res.articleType)
  })
}
onMounted(() => {
  getDictData()
  getData()
})
</script>
<style scoped>
.grid_cont {
  min-height: 600px;
  background: #fff;
}

.grid_cont2 {
  width: 100%;
  background: #fff;
  height: 65px;
  justify-content: center;
  align-items: center;
  display: flex;
  padding: 0;
  box-shadow: 0px -2px 6px 0px rgba(188, 188, 188, 0.65);
}

.grid_btn {
  width: 80px;
  height: 30px;
}

.grid_btn:hover {
  opacity: 0.8;
}

::v-deep .el-radio__input.is-checked .el-radio__inner {
  border-color: #cc352f !important;
  background-color: #cc352f !important;
}

::v-deep .el-radio__inner:hover {
  border-color: #cc352f !important;
}

::v-deep .el-radio__input.is-checked + .el-radio__label {
  color: #cc352f !important;
}

::v-deep .el-cascader .el-input.is-focus .el-input__wrapper {
  box-shadow: 0 0 0 1px #cc352f !important;
}

.introducestyle {
  box-shadow: 0 0 0 1px var(--el-disabled-border-color);
  border-radius: 4px;
  background: transparent !important;
}
.introducestyle::selection {
  box-shadow: 0 0 0 1px #cc352f !important;
}

::v-deep .w-e-text-placeholder {
  top: 10px;
  text-align: justify;
  width: 96%;
}

::v-deep .w-e-bar {
  background: transparent !important;
}

::v-deep .w-e-text-container {
  background: transparent !important;
}

::v-deep .w-e-bar {
  box-shadow: 0px 1px 0px 0px var(--el-disabled-border-color);
  pointer-events: none;
  cursor: not-allowed;
  background: var(--el-disabled-bg-color) !important;
}

::v-deep .border-solid {
  border-color: var(--el-disabled-bg-color);
  border-radius: 4px;
}

:deep(.w-e-text-container [data-slate-editor] img) {
  cursor: not-allowed !important;
}

:deep(.w-e-text-container [data-slate-editor]) {
  background: var(--el-disabled-bg-color) !important;
}
.btnhover:hover {
  opacity: 0.8;
}

.themedata {
  margin-bottom: 20px;
  padding: 0 30px;
}

.theme-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
}

.theme-item:last-child {
  margin-bottom: 0;
}

.theme-content {
  width: calc(100% - 30px);
  border: 1px dashed #868686;
  background: #e4e4e4;
  padding: 20px;
  box-sizing: border-box;
}

.theme-item ::v-deep .el-checkbox__label {
  display: none;
}

.theme-content ::v-deep .el-checkbox__label {
  display: block;
}
.grid_btn {
  width: 80px;
  height: 30px;
  background-color: #ff9900;
  border: none;
  color: #fff;
}

.grid_btn:hover {
  opacity: 0.8;
}
:deep(.w-e-text-container [data-slate-editor] p){
  color:#a8abb2;
}
</style>
